import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'
import { AdminUserService } from './admin-user.service'
import { BaseController } from '@/base/base.controller'
import { AdminUser } from '@prisma/client'
import { AdminUserDto } from './dto/admin-user.dto'
import { AdminLoginDto } from './dto/login.dto'
import { ApiOperation, ApiTags } from '@nestjs/swagger'

@ApiTags('管理员')
@Controller('admin-user')
export class AdminUserController extends BaseController<AdminUser, AdminUserDto> {
  constructor(private readonly adminUserService: AdminUserService) {
    super(adminUserService)
  }

  @ApiOperation({ summary: '管理员登录', description: '管理员登录' })
  @Post('login')
  async login(@Body() dto: AdminLoginDto) {
    return await this.adminUserService.login(dto)
  }

  @ApiOperation({ summary: '修改密码', description: '修改密码' })
  @Patch('changePass/:id')
  async changePass(@Param('id') id: string, @Body() dto: { old_pass: string; new_pass: string }) {
    return await this.adminUserService.changePass(id, dto.old_pass, dto.new_pass)
  }
}
